#
import argparse
from typing import Dict
from pathlib import Path
from apps.clip.clip_app import ClipApp

def main(params:Dict = {}) -> None:
    print(f'主程序入口')

def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--run_mode', action='store',
        type=int, default=1, dest='run_mode',
        help='run mode'
    )
    parser.add_argument(
        '--task', action='store',
        type=int, default=1, dest='task',
        help='task'
    )
    return parser.parse_args()

# torchrun --nproc_per_node=4 app_main.py --model tost_cab_tiny_12_p16 --batch-size 64 --drop-path 0.0 --output_dir ../work/outputs/tost_cab_tiny_12_p16/ --epochs 400
def dist_main() -> None: 
    parser = argparse.ArgumentParser('ToST training and evaluation script', parents=[ClipApp.get_args_parser()])
    args = parser.parse_args()
    if args.output_dir:
        Path(args.output_dir).mkdir(parents=True, exist_ok=True)
    ClipApp.tost_main(args)

if '__main__' == __name__:
    i_mode = 1
    if i_mode == 1:
        dist_main()
    else:
        args = parse_args()
        params = vars(args)
        main(params=params)